package com.cxria.shiro.dto;

import com.cxria.shiro.enums.ShiroStatusCodeEnum;
import com.cxria.shiro.enums.ShiroStatusMsgEnum;
import org.springframework.data.domain.Page;

import java.util.List;

public class ShiroStatus<T> {

	public static final String SUCCESS = "success";
	public static final String ERROR = "error";

	private String status = SUCCESS;
	private String statusCode = ShiroStatusCodeEnum.NORMAL.toString();
	private String statusMsg = ShiroStatusMsgEnum.NORMAL.toString();

	private Object entity;

	public ShiroStatus() {

	}

	public ShiroStatus(Page<T> page) {
		List<T> list = page.getContent();
		entity = list;
	}

	public ShiroStatus(T entity) {
		this.entity = entity;
	}

	public ShiroStatus(String status, ShiroStatusCodeEnum statusCode, String msg) {
		this.status = status;
		this.statusCode = statusCode.toString();
		this.statusMsg = msg;
	}

	public ShiroStatus(String status, ShiroStatusCodeEnum statusCode, ShiroStatusMsgEnum statusMsgEnum) {
		this.status = status;
		this.statusCode = statusCode.toString();
		this.statusMsg = statusMsgEnum.toString();
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(String statusCode) {
		this.statusCode = statusCode;
	}

	public String getStatusMsg() {
		return statusMsg;
	}

	public void setStatusMsg(String statusMsg) {
		this.statusMsg = statusMsg;
	}

	public Object getEntity() {
		return entity;
	}

	public void setEntity(Object entity) {
		this.entity = entity;
	}
}
